package threads;

import java.util.concurrent.CountDownLatch;

public class CountDownLatchTest {
    private static CountDownLatch latch = new CountDownLatch(100);

    public static void main(String[] args) throws InterruptedException {
        for (int i = 0; i < 100; i++) {
            Thread thread = new Thread(new Runnable() {
                @Override
                public void run() {
                    latch.countDown();
                }
            });
            thread.start();
        }
        latch.await();
        System.out.println("栅栏打开了：所有线程都执行完成了");
    }
}
